package com.zhuoshi.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zhuoshi.bean.CustomerQuery;
import com.zhuoshi.bean.WdHtCustomer;
import com.zhuoshi.service.WdHtCustomerService;

@Controller
@RequestMapping("/customer")  //鍛藉悕绌洪棿
public class WdHtCustomerController {
	@Autowired
	private WdHtCustomerService service;

	/**
	 * 鏌ヨ鍏ㄩ儴锛屾湁鏉′欢鏌ヨ
	 * @param bean
	 * @param model
	 * @return
	 */
	@RequestMapping("/WdCustomerList.do")
	public String list(CustomerQuery bean, Model model) {
		List<WdHtCustomer> list = service.getlist(bean);
		model.addAttribute("WdCustomerList", list);
		return "WdCustomerList";

	}

	/**
	 * 娣诲姞
	 * @return
	 */
	@RequestMapping("/WdCustomerToAdd.do")
	public String toadd() {
		return "WdCustomerAdd";

	}

	/**
	 * 鍔ㄦ�佹坊鍔�
	 * @param customer
	 * @return
	 */
	@RequestMapping("/WdCustomerAdd.do")
	public String add(WdHtCustomer customer) {
		service.insertSelective(customer);
		return "redirect:WdCustomerList.do";

	}

	/**
	 * 鍒犻櫎
	 * @param customerId
	 * @return
	 */
	@RequestMapping("/WdCustomerDelete.do")
	public String delete(String customerId) {
		service.deleteByPrimaryKey(customerId);
		return "redirect:WdCustomerList.do";

	}

	/**
	 * 淇敼锛屾牴鎹甶d鏌ヨ鏄剧ず淇敼
	 * @param customerId
	 * @param model
	 * @return
	 */
	@RequestMapping("/WdCustomerToUpdate.do")
	public String toupdate(String customerId, Model model) {
		WdHtCustomer customer = service.selectByPrimaryKey(customerId);
		model.addAttribute("customer", customer);
		return "WdCustomerUpdate";
	}

	/**
	 * 鍔ㄦ�佷慨鏀�
	 * @param customer
	 * @return
	 */
	@RequestMapping("/WdCustomerUpdate.do")
	public String update(WdHtCustomer customer) {
		service.updateByPrimaryKeySelective(customer);
		return "redirect:WdCustomerList.do";
	}
}
